package com.example.userservice;

import com.example.userservice.novel.entity.NovelStructure;
import com.example.userservice.novel.service.SimpleNovelService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
public class UserServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(UserServiceApplication.class, args);
    }

    @Bean
    public CommandLineRunner demo(SimpleNovelService simpleNovelService) {
        return (args) -> {
            if (args.length > 0) {
                String novelName = args[0];
                NovelStructure structure = simpleNovelService.generateNovelStructure(novelName);

                System.out.println("生成完成！");
                System.out.println("主题: " + structure.getTheme());
                System.out.println("角色数量: " + structure.getMainCharacters().size());
                System.out.println("大纲长度: " + structure.getPlotOutline().length());
            } else {
                System.out.println("请输入小说名称，例如: java -jar app.jar 《星辰之海》");
            }
        };
    }
}